<div class="form">

	<?php
	$form = $this->beginWidget('CActiveForm',
		array(
		'id'=>'registration-form',
		'htmlOptions'=>array('enctype'=>'multipart/form-data'),
		'enableAjaxValidation'=>false,
		));
	?>

	<?php echo $form->errorSummary($model); ?>

	<fieldset>
		<legend>Utusan:</legend>
		<div class="row">
			<?php
			echo $form->label($model, 'envoy');
			?>
			<?php
			echo $form->dropDownList($model, 'envoy', $model->envoyList);
			?>
			<?php echo $form->error($model, 'envoy'); ?>
		</div>

		<div class="row">
			<?php
			echo $form->label($model, 'envoyProvince');
			?>
			<?php
			$properties = array(
				'model'=>$model,
				'attribute'=>'envoyProvince',
				'source'=>$this->createUrl('province/autoComplete'),
				'htmlOptions'=>array('placeholder'=>'Any'),
				'options'=>array('showAnim'=>'fold'),
			);
			$this->widget('zii.widgets.jui.CJuiAutoComplete', $properties);
			?>
			<?php echo $form->error($model, 'envoyProvince');
			?>
		</div>

		<?php
		$style = '';
		if (!$model->envoy || $model->envoy == Registration::ENVOY_PROVINCE)
			$style = 'style="display: none"';
		?>
		<div class="row" id="envoy-province-row" <?php echo $style; ?>>
			<?php
			echo $form->label($model, 'envoyCity');
			?>
			<?php
			$properties = array(
				'model'=>$model,
				'attribute'=>'envoyCity',
				'source'=>$this->createUrl('city/autoComplete'),
				'htmlOptions'=>array('placeholder'=>'Any'),
				'options'=>array('showAnim'=>'fold'),
			);
			$this->widget(
				'zii.widgets.jui.CJuiAutoComplete', $properties
			);
			?>
			<?php echo $form->error($model, 'envoyCity');
			?>
		</div>
	</fieldset>

	<div class="row">
		<?php
		echo $form->label($model, 'file');
		?>
		<?php echo $form->fileField($model, 'file'); ?>
		<?php
		echo $form->error($model, 'file');
		?>
	</div>

	<div class="row">
		<?php echo $form->label($model, 'name');
		?>
		<?php
		echo $form->textField(
			$model, 'name', array('size'=>60, 'maxlength'=>255)
		);
		?>
		<?php echo $form->error($model, 'name');
		?>
	</div>

	<div class="row">
		<?php
		echo $form->label($model, 'birthPlace');
		?>
		<?php
		echo $form->textField(
			$model, 'birthPlace', array('size'=>60, 'maxlength'=>255)
		);
		?>
		<?php echo $form->error($model, 'birthPlace');
		?>
	</div>

	<div class="row">
		<?php
		echo $form->label($model, 'birthDate');
		?>
		<table>
			<tr>
				<td>
					<?php
					$dates = array();
					for ($i = 1; $i <= 31; $i++) {
						$dates[$i] = $i;
					}
					echo $form->dropDownList($model, 'birthDay', $dates);
					?>
				</td>
				<td>
					<?php
					$months = array(1=>'Januari', 'Februari', 'Maret', 'April',
						'Mei', 'Juni', 'Juli', 'Agustus', 'September',
						'Oktober', 'November', 'Desember');
					echo $form->dropDownList($model, 'birthMonth', $months);
					?>
				</td>
				<td>
					<?php
					echo $form->textField(
						$model, 'birthYear', array('style'=>'width: 4em;')
					);
					?>
				</td>
			</tr>
		</table>
		<?php
		echo $form->error($model, 'birthDate');
		?>
	</div>

	<div class="row">
		<?php echo $form->label($model, 'emails');
		?>
		<?php
		echo $form->textField(
			$model, 'emails', array('size'=>60, 'maxlength'=>255)
		);
		?>
		<?php echo $form->error($model, 'emails');
		?>
	</div>

	<div class="row">
		<?php echo $form->label($model, 'phones');
		?>
		<?php
		echo $form->textField(
			$model, 'phones', array('size'=>60, 'maxlength'=>255)
		);
		?>
		<?php echo $form->error($model, 'phones');
		?>
	</div>

	<div class="row">
		<?php echo $form->label($model, 'position');
		?>
		<?php
		echo $form->textField(
			$model, 'position', array('size'=>60, 'maxlength'=>255)
		);
		?>
		<?php echo $form->error($model, 'position');
		?>
	</div>

	<fieldset>
		<legend>Rumah / KTP:</legend>
		<div class="row">
			<?php
			echo $form->label($model, 'homeAddress');
			?>
			<?php
			echo $form->textArea(
				$model, 'homeAddress', array('rows'=>6, 'cols'=>50)
			);
			?>
			<?php echo $form->error($model, 'homeAddress');
			?>
		</div>

		<div class="row">
			<?php
			echo $form->label($model, 'homeCity');
			?>
			<table>
				<tr>
					<td>
						<?php
						echo $form->dropDownList(
							$model, 'homeCityType', $model->cityTypeList
						);
						?>
					</td>
					<td class="fill">
						<?php
						$properties = array(
							'model'=>$model,
							'attribute'=>'homeCity',
							'source'=>$this->createUrl('city/autoComplete'),
							'htmlOptions'=>array('placeholder'=>'Any'),
							'options'=>array('showAnim'=>'fold'),
						);
						$this->widget(
							'zii.widgets.jui.CJuiAutoComplete', $properties
						);
						?>
					</td>
				</tr>
			</table>
			<?php
			echo $form->error($model, 'homeCity');
			?>
		</div>

		<div class="row">
			<?php
			echo $form->label($model, 'province');
			?>
			<?php
			$properties = array(
				'model'=>$model,
				'attribute'=>'province',
				'source'=>$this->createUrl('province/autoComplete'),
				'htmlOptions'=>array('placeholder'=>'Any'),
				'options'=>array('showAnim'=>'fold'),
			);
			$this->widget('zii.widgets.jui.CJuiAutoComplete', $properties);
			?>
			<?php echo $form->error($model, 'province');
			?>
		</div>
	</fieldset>

	<div class="row buttons">
		<?php
		echo CHtml::submitButton($model->isNewRecord ? 'Create' : 'Save');
		?>
	</div>

	<?php $this->endWidget(); ?>

</div><!-- form -->

<script type="text/javascript">
	$('#Registration_envoy').change(
	function() {
		if ($(this).attr('value') == 'Propinsi') {
			$('#envoy-province-row').hide();
		} else {
			$('#envoy-province-row').show();
		}
	}
);
</script>